<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<%@ include file="../common/common.jsp"%>
		<script type="text/javascript" src="${ctx}/lib/datatables/1.10.0/jquery.dataTables.min.js"></script>
		<title>积分账户流水列表</title>
	</head>

	<body>
		<input id="topic_id" type="hidden" value="${topicId}"/>
		<div class="page-container">
			<div class="cl pd-5 bg-1 bk-gray mt-20">
				<span class="l">
					<i class="Hui-iconfont">&#xe6b5;</i> 当前积分余额:&nbsp<strong><fmt:formatNumber type="number" value="${pointAccount.currentValue}" pattern="0.00" maxFractionDigits="2"/></strong>
				</span>
			</div>
			<div class="mt-20">
				<table id="table" class="table table-border table-bordered table-bg table-hover table-sort">
					<thead>
						<tr class="text-c">
							<th width="25"><input type="checkbox" name="checkAll" value=""></th>
							<th>序号</th>
							<th>变动前的积分值</th>
							<th>变动后的积分值</th>
							<th>变动的值</th>
							<th>变动时间</th>
							<th>备注</th>
						</tr>
					</thead>
				<tbody>
					<tr class="text-c">
						<td colspan="9">数据获取中....</td>
					</tr>
				</tbody>
			</table>
			</div>
		</div>
	<script type="text/javascript">
			var memberId = "${memberId}";
			$('#table').dataTable({
				"dom": '<"datatable-header"<"dataTables_filter">l><"datatable-scroll"t><"datatable-footer"ip>',
				"aaSorting": [[ 5, "asc" ]],//默认第几个排序
				"bStateSave": false,//状态保存
				"aoColumnDefs": [
				     			//{"bVisible": false, "aTargets": [ 3 ]} //控制列的隐藏显示
				     			{"orderable":false,"aTargets":[0,1,6]} // 不参与排序的列
				     		],
				"columnDefs":[
				    		  	{
				    		  		//设置列不参与搜索
				    		  		"targets":[0,1,2,3,4,5,6],
				    		  		"serchable":false
				    		  	}
				    		  ],
				"bProcessing": true, //开启读取服务器数据时显示正在加载中……特别是大数据量的时候，开启此功能比较好
				"bServerSide": true,
				"sAjaxSource": ctx + "/pointAccountTraceManage/findPointAccountTracePage.do?memberId=" + memberId,//ajax地址 
	          	//配置列要显示的数据
	            "aoColumns": [
					{"sDefaultContent": ''},
					{"sDefaultContent": ''},
					{ "mData": "beforeValue" },
	            	{ "mData": "afterValue" },
	            	{ "mData": "changeValue" },
	            	{ "mData": "changeTime" },
	            	{ "mData": "remark" }
	            ],
				"fnServerData": retrieveData,//执行方法
				"fnRowCallback": fnRowCallback
			});
			
		function retrieveData(sSource, aoData, fnCallback) {
			var index = layer.load(0, {shade: false});
		    $.ajax({
		        type: "POST",
		        contentType: "application/x-www-form-urlencoded",
		        url: sSource,
		        dataType: "json",
		        data: aoData, 
		        success: function (resp) {
		        	layer.close(index);
		        	if(resp.code != "ok"){
						console.log("返回失败", resp);
						layer.msg(resp.msg,{icon: 5,time:2000});
		        	}else{
		        		var bizData = resp.object;
				        var data={
								"sEcho":bizData.userdata.sEcho, //当前显示的第一条数据
								"iTotalRecords":bizData.records,  //总记录数
								"iTotalDisplayRecords":bizData.records,  //当前显示的总记录数
								"aaData":bizData.rows //数据列表
				        };
				        fnCallback(data); //服务器端返回的对象的returnObject部分是要求的格式  	
		        	}
		        },
				error: function(data) {
					console.log("返回失败", data);
					layer.close(index);
					layer.msg(data.msg,{icon: 5,time:2000});
					$("table tbody").html('<tr class="text-c"><td colspan="11">'+data.msg+'...</td></tr>');
				}
		    });
		}
		
		// 当创建了行，但还未绘制到屏幕上的时候调用，通常用于改变行的
		function fnRowCallback(nRow, aData, iDisplayIndex) {
			$(nRow).addClass('text-c');
			$('td:eq(0)', nRow).html("<input type='checkbox' value='"+aData.id+"' name='del'>");
			$('td:eq(1)', nRow).html(iDisplayIndex+1);
			$('td:eq(5)', nRow).html(dates(aData.changeTime));
/* 			if(aData.content.length>20){
				$('td:eq(2)', nRow).html(aData.content.substring(0,21) + "...");
			}else{
				$('td:eq(2)', nRow).html(aData.content);
			}
			$('td:eq(5)', nRow).html(dates(aData.createTime));
			var deleteHtml = "<a style='text-decoration:none' class='ml-5' onClick=replyDel(this,'"+aData.id+"')  href='javascript:;' title='删除'>删除</a>"
			var showHtml = "<a style='text-decoration:none' class='ml-5' onClick=showDetail('"+aData.id+"')  href='javascript:;' title='详情'>详情</a>"
			$('td:eq(6)', nRow).html(showHtml+deleteHtml); */
			return nRow;
		}
	</script>

</body>

</html>